<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<title>阳光成单系统</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link rel="stylesheet" href="./css/x-admin.css" media="all">
<link rel="stylesheet" href="js/layui/css/layui.css" media="all">
<script type="text/javascript" src="js/layui/layui.js"></script>
</head>

<body>
	<div class="x-body">
		<form class="layui-form" id="design-add-form" onsubmit="return false">
			</div>
			<div class="layui-form-item">
				<label for="link" class="layui-form-label"> <span
					class="x-red">*</span>点击上传
				</label>
				<button type="button" class="layui-btn" id="design">
					<i class="layui-icon">&#xe67c;</i>上传图片
				</button>
			</div>
			<div class="layui-form-item">
				<label for="link" class="layui-form-label"> <span
					class="x-red">*</span>设计师头像
				</label>
				<div class="layui-input-inline">
					<div class="site-demo-upbar">
						<img id="imgFace" style="width: 120px" src="" />
					</div>
				</div>
			<div class="layui-form-item">
				<label for="link" class="layui-form-label"> <span
					class="x-red">*</span>设计师名称
				</label>
				<div class="layui-input-inline">
					<input name="designName" id="designName" value="" class="layui-input" placeholder="设计师名字">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="link" class="layui-form-label"> <span
					class="x-red">*</span>图片路径
				</label>
				<div class="layui-input-inline">
					<input name="picName" id="picName" value="" class="layui-input" placeholder="图片路径自动生成">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="link" class="layui-form-label"> <span
					class="x-red">*</span>设计师等级
				</label>
				<div class="layui-input-inline">
					<input name="designGrade" id="designGrade" value="" class="layui-input" placeholder="雷霆嘎巴级">
				</div>
			</div>
			<div class="layui-form-item">
				<label for="L_repass" class="layui-form-label"> </label>
				<button class="layui-btn" lay-filter="add" onclick="addDesign()">添加</button>
			</div>
		</form>
	</div>
	<script src="./lib/layui/layui.js" charset="utf-8">
		
	</script>
	<script src="./js/x-layui.js" charset="utf-8">
		
	</script>
	<script>
		var $ = null;
		var form = null;
		var layer = null;
		var upload = null;
		layui.use([ 'form', 'layer', 'upload' ], function() {
			$ = layui.jquery;
			form = layui.form;
			upload = layui.upload;
			layer = layui.layer;

			//执行实例
			var uploadInst = upload.render({
				elem : '#design', //绑定元素
				url : '../adminJson?reqName=upload', //上传接口
				acceptMime : 'images/*',//只显示图片
				done : function(res) {
					//上传完毕回调
					if (res.success) {
						$("#imgFace").attr("src", "../images/" + res.remark);//回显图片
						$("#picName").val("images/" + res.remark);//回显路径
						layer.msg("上传成功", {
							icon : 6,//图标
							time : 1500//显示时间
						});
					}
				},
				error : function() {
					//请求异常回调
				}
			});

		});
		
		//添加设计师
		function addDesign(){
			/* if(cateName == null || cateName==""){
				return false;//停止代码
			}  */         
			$.post("../adminDesign?reqName=addDesign",$("#design-add-form").serialize(),function(res){
				if(res.success){
					layer.msg(res.message);
					var index = parent.layer.getFrameIndex(window.name);
					parent.layer.close(index);//关闭当前页
					//当成功关闭页面之后,重新调用查询方法
					parent.myPage();
				}else{
					layer.msg(res.message);
				}
			},"json");
        	
        }
	</script>

</body>

</html>